   1              		.syntax unified
   2              		.cpu cortex-m3
   3              		.fpu softvfp
   4              		.eabi_attribute 20, 1
   5              		.eabi_attribute 21, 1
   6              		.eabi_attribute 23, 3
   7              		.eabi_attribute 24, 1
   8              		.eabi_attribute 25, 1
   9              		.eabi_attribute 26, 1
  10              		.eabi_attribute 30, 4
  11              		.eabi_attribute 34, 1
  12              		.eabi_attribute 18, 4
  13              		.thumb
  14              		.syntax unified
  15              		.file	"joyps.c"
  16              		.text
  17              	.Ltext0:
  18              		.cfi_sections	.debug_frame
  19              		.section	.text.__swap,"ax",%progbits
  20              		.align	1
  21              		.thumb
  22              		.thumb_func
  24              	__swap:
  25              	.LFB2:
  26              		.file 1 "uc_libc_dev/sensor/joyps.c"
   1:uc_libc_dev/sensor/joyps.c **** /*
   2:uc_libc_dev/sensor/joyps.c **** 	Driver para joystick de playstation ID=0x41 e 0x73
   3:uc_libc_dev/sensor/joyps.c **** 	Esta biblioteca somente lê valores digitais dos botões, não faz controle de vibração ou configuraç
   4:uc_libc_dev/sensor/joyps.c **** */
   5:uc_libc_dev/sensor/joyps.c **** 
   6:uc_libc_dev/sensor/joyps.c **** #include "joyps.h"
   7:uc_libc_dev/sensor/joyps.c **** 
   8:uc_libc_dev/sensor/joyps.c **** static volatile int joy;
   9:uc_libc_dev/sensor/joyps.c **** 
  10:uc_libc_dev/sensor/joyps.c **** // ################################################################################################
  11:uc_libc_dev/sensor/joyps.c **** // FUNÇÕES GLOBAIS
  12:uc_libc_dev/sensor/joyps.c **** // ################################################################################################
  13:uc_libc_dev/sensor/joyps.c **** 
  14:uc_libc_dev/sensor/joyps.c **** //-------------------------------------------------------------------------------------------------
  15:uc_libc_dev/sensor/joyps.c **** // Descrição: Configura o pino CHIP SELECT
  16:uc_libc_dev/sensor/joyps.c **** //-------------------------------------------------------------------------------------------------
  17:uc_libc_dev/sensor/joyps.c **** 
  18:uc_libc_dev/sensor/joyps.c **** // O joystick trabalha com CPOL=1 e CPHA=1.
  19:uc_libc_dev/sensor/joyps.c **** void joy_Init(void) {
  20:uc_libc_dev/sensor/joyps.c **** 	joyps_SetupPorts();	// Configurar o pino CS
  21:uc_libc_dev/sensor/joyps.c ****     joyps_Disable();
  22:uc_libc_dev/sensor/joyps.c ****     joy = 0;
  23:uc_libc_dev/sensor/joyps.c **** }
  24:uc_libc_dev/sensor/joyps.c **** 
  25:uc_libc_dev/sensor/joyps.c **** // retonra com o valor da tecla pressionada.
  26:uc_libc_dev/sensor/joyps.c **** int joy_Read(void) {
  27:uc_libc_dev/sensor/joyps.c **** 	int j = joy; // retorna com o valor da tecla pressionada
  28:uc_libc_dev/sensor/joyps.c **** 	joy = 0; // sinaliza que não tem mais tecla sendo pressionada
  29:uc_libc_dev/sensor/joyps.c **** 	return j;
  30:uc_libc_dev/sensor/joyps.c **** }
  31:uc_libc_dev/sensor/joyps.c **** 
  32:uc_libc_dev/sensor/joyps.c **** static u8 __swap(u8 v) {
  27              		.loc 1 32 0
  28              		.cfi_startproc
  29              		@ args = 0, pretend = 0, frame = 0
  30              		@ frame_needed = 0, uses_anonymous_args = 0
  31              	.LVL0:
  33:uc_libc_dev/sensor/joyps.c **** 	#if defined(usesSSP) // bus ssp não tem transmissão LSB
  34:uc_libc_dev/sensor/joyps.c **** 	u8 aux = 0;
  35:uc_libc_dev/sensor/joyps.c **** 	int x; for (x=0; x < 8; x++) if ((v&_BV(x)) > 0) aux |= _BV(7-x);
  32              		.loc 1 35 0
  33 0000 0023     		movs	r3, #0
  34:uc_libc_dev/sensor/joyps.c **** 	int x; for (x=0; x < 8; x++) if ((v&_BV(x)) > 0) aux |= _BV(7-x);
  34              		.loc 1 34 0
  35 0002 1A46     		mov	r2, r3
  32:uc_libc_dev/sensor/joyps.c **** 	#if defined(usesSSP) // bus ssp não tem transmissão LSB
  36              		.loc 1 32 0
  37 0004 10B5     		push	{r4, lr}
  38              	.LCFI0:
  39              		.cfi_def_cfa_offset 8
  40              		.cfi_offset 4, -8
  41              		.cfi_offset 14, -4
  42              		.loc 1 35 0
  43 0006 0124     		movs	r4, #1
  44              	.LVL1:
  45              	.L3:
  46              		.loc 1 35 0 is_stmt 0 discriminator 6
  47 0008 04FA03F1 		lsl	r1, r4, r3
  48 000c 0142     		tst	r1, r0
  49 000e 1EBF     		ittt	ne
  50 0010 C3F10701 		rsbne	r1, r3, #7
  51 0014 04FA01F1 		lslne	r1, r4, r1
  52 0018 0A43     		orrne	r2, r2, r1
  53              	.LVL2:
  54 001a 03F10103 		add	r3, r3, #1
  55              	.LVL3:
  56 001e 18BF     		it	ne
  57 0020 D2B2     		uxtbne	r2, r2
  58              	.LVL4:
  59 0022 082B     		cmp	r3, #8
  60 0024 F0D1     		bne	.L3
  36:uc_libc_dev/sensor/joyps.c **** 	return aux;
  37:uc_libc_dev/sensor/joyps.c **** 	#else
  38:uc_libc_dev/sensor/joyps.c **** 	return v;
  39:uc_libc_dev/sensor/joyps.c **** 	#endif
  40:uc_libc_dev/sensor/joyps.c **** }
  61              		.loc 1 40 0 is_stmt 1
  62 0026 1046     		mov	r0, r2
  63              	.LVL5:
  64 0028 10BD     		pop	{r4, pc}
  65              		.cfi_endproc
  66              	.LFE2:
  68              		.section	.text.joy_Init,"ax",%progbits
  69              		.align	1
  70              		.global	joy_Init
  71              		.thumb
  72              		.thumb_func
  74              	joy_Init:
  75              	.LFB0:
  19:uc_libc_dev/sensor/joyps.c **** 	joyps_SetupPorts();	// Configurar o pino CS
  76              		.loc 1 19 0
  77              		.cfi_startproc
  78              		@ args = 0, pretend = 0, frame = 0
  79              		@ frame_needed = 0, uses_anonymous_args = 0
  80              		@ link register save eliminated.
  20:uc_libc_dev/sensor/joyps.c ****     joyps_Disable();
  81              		.loc 1 20 0
  82 0000 064A     		ldr	r2, .L10
  83 0002 1368     		ldr	r3, [r2]
  84 0004 43F48023 		orr	r3, r3, #262144
  85 0008 1360     		str	r3, [r2]
  21:uc_libc_dev/sensor/joyps.c ****     joy = 0;
  86              		.loc 1 21 0
  87 000a 054B     		ldr	r3, .L10+4
  88 000c 4FF48022 		mov	r2, #262144
  89 0010 1A60     		str	r2, [r3]
  22:uc_libc_dev/sensor/joyps.c **** }
  90              		.loc 1 22 0
  91 0012 044B     		ldr	r3, .L10+8
  92 0014 0022     		movs	r2, #0
  93 0016 1A60     		str	r2, [r3]
  94 0018 7047     		bx	lr
  95              	.L11:
  96 001a 00BF     		.align	2
  97              	.L10:
  98 001c 00C00920 		.word	537509888
  99 0020 18C00920 		.word	537509912
 100 0024 00000000 		.word	.LANCHOR0
 101              		.cfi_endproc
 102              	.LFE0:
 104              		.section	.text.joy_Read,"ax",%progbits
 105              		.align	1
 106              		.global	joy_Read
 107              		.thumb
 108              		.thumb_func
 110              	joy_Read:
 111              	.LFB1:
  26:uc_libc_dev/sensor/joyps.c **** 	int j = joy; // retorna com o valor da tecla pressionada
 112              		.loc 1 26 0
 113              		.cfi_startproc
 114              		@ args = 0, pretend = 0, frame = 0
 115              		@ frame_needed = 0, uses_anonymous_args = 0
 116              		@ link register save eliminated.
  27:uc_libc_dev/sensor/joyps.c **** 	joy = 0; // sinaliza que não tem mais tecla sendo pressionada
 117              		.loc 1 27 0
 118 0000 024B     		ldr	r3, .L13
  28:uc_libc_dev/sensor/joyps.c **** 	return j;
 119              		.loc 1 28 0
 120 0002 0022     		movs	r2, #0
  27:uc_libc_dev/sensor/joyps.c **** 	joy = 0; // sinaliza que não tem mais tecla sendo pressionada
 121              		.loc 1 27 0
 122 0004 1868     		ldr	r0, [r3]
 123              	.LVL6:
  28:uc_libc_dev/sensor/joyps.c **** 	return j;
 124              		.loc 1 28 0
 125 0006 1A60     		str	r2, [r3]
  30:uc_libc_dev/sensor/joyps.c **** 
 126              		.loc 1 30 0
 127 0008 7047     		bx	lr
 128              	.L14:
 129 000a 00BF     		.align	2
 130              	.L13:
 131 000c 00000000 		.word	.LANCHOR0
 132              		.cfi_endproc
 133              	.LFE1:
 135              		.section	.text.joy_Tick,"ax",%progbits
 136              		.align	1
 137              		.global	joy_Tick
 138              		.thumb
 139              		.thumb_func
 141              	joy_Tick:
 142              	.LFB4:
  41:uc_libc_dev/sensor/joyps.c **** 
  42:uc_libc_dev/sensor/joyps.c **** static int __joy_ReadControls(int* ctrl ) {
  43:uc_libc_dev/sensor/joyps.c **** 	joyps_Enable();
  44:uc_libc_dev/sensor/joyps.c **** 	joyps_TransferByte(__swap(0x1)); // Envio o byte para inicializar transferencia ao controle PS1
  45:uc_libc_dev/sensor/joyps.c **** 	int id = __swap(joyps_TransferByte(__swap(0x42))); // Envio o byte de quesito de dados do controle
  46:uc_libc_dev/sensor/joyps.c **** 	joyps_TransferByte(0);	// Envio qualquer valor para o controle para receber dele o indicador de in
  47:uc_libc_dev/sensor/joyps.c **** 	int b1 = __swap(~joyps_TransferByte(0)); // Envio qualquer valor para o controle para receber dele
  48:uc_libc_dev/sensor/joyps.c **** 	int b2 = __swap(~joyps_TransferByte(0)); // Envio qualquer valor para o controle para receber dele
  49:uc_libc_dev/sensor/joyps.c **** 	// somente para joystick com suporte analógico.
  50:uc_libc_dev/sensor/joyps.c **** 	//	int a1 = __swap(~joyps_TransferByte(0));
  51:uc_libc_dev/sensor/joyps.c **** 	//	int a2 = __swap(~joyps_TransferByte(0));
  52:uc_libc_dev/sensor/joyps.c **** 	//	int a3 = __swap(~joyps_TransferByte(0));
  53:uc_libc_dev/sensor/joyps.c **** 	//	int a4 = __swap(~joyps_TransferByte(0));
  54:uc_libc_dev/sensor/joyps.c **** 	joyps_Disable();
  55:uc_libc_dev/sensor/joyps.c **** 
  56:uc_libc_dev/sensor/joyps.c **** 	*ctrl = (b1 << 8) | b2;
  57:uc_libc_dev/sensor/joyps.c **** 	return id;
  58:uc_libc_dev/sensor/joyps.c **** }
  59:uc_libc_dev/sensor/joyps.c **** 
  60:uc_libc_dev/sensor/joyps.c **** // Chamar esta função a cada 1ms
  61:uc_libc_dev/sensor/joyps.c **** // ATENÇÃO: O acesso SPI ao joystick foge do padrão dos demais dispositivos que usamos.
  62:uc_libc_dev/sensor/joyps.c **** //			Caso isto está usando o mesmo barramento SPI para acessar outros dipositivos que são de padrõe
  63:uc_libc_dev/sensor/joyps.c **** //				diferentes é preciso utiliza uma subchamada da rotina joy_Tick trocando as condições de acess
  64:uc_libc_dev/sensor/joyps.c **** //			Exemplo:
  65:uc_libc_dev/sensor/joyps.c **** //				void joy_Tick2(void) {
  66:uc_libc_dev/sensor/joyps.c **** //					ssp1_Init(SSP0_MASTER, SSP0_CPOL_H|SSP0_CPHA_H|SSP0_DSS_8); // inicar o barramento SPI a 400
  67:uc_libc_dev/sensor/joyps.c **** //				    joy_Tick();
  68:uc_libc_dev/sensor/joyps.c **** //					ssp1_Init(SSP0_MASTER, SSP0_STANDARD); // inicar o barramento SPI a 400Khz
  69:uc_libc_dev/sensor/joyps.c **** //				}
  70:uc_libc_dev/sensor/joyps.c **** void joy_Tick(void) {
 143              		.loc 1 70 0
 144              		.cfi_startproc
 145              		@ args = 0, pretend = 0, frame = 0
 146              		@ frame_needed = 0, uses_anonymous_args = 0
  71:uc_libc_dev/sensor/joyps.c **** 	// LEITURA DO JOYSTICK a cada 16ms
  72:uc_libc_dev/sensor/joyps.c **** 	// 	Ler a cada 16ms já é o suficiente para uma boa resposta
  73:uc_libc_dev/sensor/joyps.c **** 	static volatile uint timeRead = 0;
  74:uc_libc_dev/sensor/joyps.c **** 	if (timeRead) timeRead--;
 147              		.loc 1 74 0
 148 0000 194B     		ldr	r3, .L26
  70:uc_libc_dev/sensor/joyps.c **** 	// LEITURA DO JOYSTICK a cada 16ms
 149              		.loc 1 70 0
 150 0002 70B5     		push	{r4, r5, r6, lr}
 151              	.LCFI1:
 152              		.cfi_def_cfa_offset 16
 153              		.cfi_offset 4, -16
 154              		.cfi_offset 5, -12
 155              		.cfi_offset 6, -8
 156              		.cfi_offset 14, -4
 157              		.loc 1 74 0
 158 0004 1A68     		ldr	r2, [r3]
 159 0006 12B1     		cbz	r2, .L16
 160              		.loc 1 74 0 is_stmt 0 discriminator 1
 161 0008 1A68     		ldr	r2, [r3]
 162 000a 013A     		subs	r2, r2, #1
 163 000c 1A60     		str	r2, [r3]
 164              	.L16:
  75:uc_libc_dev/sensor/joyps.c **** 	if (timeRead == 0) {
 165              		.loc 1 75 0 is_stmt 1
 166 000e 1D68     		ldr	r5, [r3]
 167 0010 4DBB     		cbnz	r5, .L15
 168              	.LBB5:
  76:uc_libc_dev/sensor/joyps.c **** 		timeRead = 16;
 169              		.loc 1 76 0
 170 0012 154B     		ldr	r3, .L26
 171 0014 1022     		movs	r2, #16
 172 0016 1A60     		str	r2, [r3]
 173              	.LVL7:
 174              	.LBB6:
 175              	.LBB7:
  43:uc_libc_dev/sensor/joyps.c **** 	joyps_TransferByte(__swap(0x1)); // Envio o byte para inicializar transferencia ao controle PS1
 176              		.loc 1 43 0
 177 0018 144B     		ldr	r3, .L26+4
 178 001a 4FF48026 		mov	r6, #262144
 179 001e 1E60     		str	r6, [r3]
  44:uc_libc_dev/sensor/joyps.c **** 	int id = __swap(joyps_TransferByte(__swap(0x42))); // Envio o byte de quesito de dados do controle
 180              		.loc 1 44 0
 181 0020 0120     		movs	r0, #1
 182 0022 FFF7FEFF 		bl	__swap
 183              	.LVL8:
 184 0026 FFF7FEFF 		bl	ssp1_TransferByte
 185              	.LVL9:
  45:uc_libc_dev/sensor/joyps.c **** 	joyps_TransferByte(0);	// Envio qualquer valor para o controle para receber dele o indicador de in
 186              		.loc 1 45 0
 187 002a 4220     		movs	r0, #66
 188 002c FFF7FEFF 		bl	__swap
 189              	.LVL10:
 190 0030 FFF7FEFF 		bl	ssp1_TransferByte
 191              	.LVL11:
  46:uc_libc_dev/sensor/joyps.c **** 	int b1 = __swap(~joyps_TransferByte(0)); // Envio qualquer valor para o controle para receber dele
 192              		.loc 1 46 0
 193 0034 2846     		mov	r0, r5
 194 0036 FFF7FEFF 		bl	ssp1_TransferByte
 195              	.LVL12:
  47:uc_libc_dev/sensor/joyps.c **** 	int b2 = __swap(~joyps_TransferByte(0)); // Envio qualquer valor para o controle para receber dele
 196              		.loc 1 47 0
 197 003a 2846     		mov	r0, r5
 198 003c FFF7FEFF 		bl	ssp1_TransferByte
 199              	.LVL13:
 200 0040 C043     		mvns	r0, r0
 201 0042 C0B2     		uxtb	r0, r0
 202 0044 FFF7FEFF 		bl	__swap
 203              	.LVL14:
 204 0048 0446     		mov	r4, r0
 205              	.LVL15:
  48:uc_libc_dev/sensor/joyps.c **** 	// somente para joystick com suporte analógico.
 206              		.loc 1 48 0
 207 004a 2846     		mov	r0, r5
 208 004c FFF7FEFF 		bl	ssp1_TransferByte
 209              	.LVL16:
 210 0050 C043     		mvns	r0, r0
 211 0052 C0B2     		uxtb	r0, r0
 212 0054 FFF7FEFF 		bl	__swap
 213              	.LVL17:
  54:uc_libc_dev/sensor/joyps.c **** 
 214              		.loc 1 54 0
 215 0058 054B     		ldr	r3, .L26+8
 216              	.LBE7:
 217              	.LBE6:
  77:uc_libc_dev/sensor/joyps.c **** 		int buttons;
  78:uc_libc_dev/sensor/joyps.c **** 		__joy_ReadControls(&buttons);
  79:uc_libc_dev/sensor/joyps.c **** 		if (buttons > 0) joy = buttons;
 218              		.loc 1 79 0
 219 005a 50EA0420 		orrs	r0, r0, r4, lsl #8
 220              	.LVL18:
 221              	.LBB9:
 222              	.LBB8:
  54:uc_libc_dev/sensor/joyps.c **** 
 223              		.loc 1 54 0
 224 005e 1E60     		str	r6, [r3]
 225              	.LBE8:
 226              	.LBE9:
 227              		.loc 1 79 0
 228 0060 1CBF     		itt	ne
 229 0062 044B     		ldrne	r3, .L26+12
 230 0064 1860     		strne	r0, [r3]
 231              	.LVL19:
 232              	.L15:
 233 0066 70BD     		pop	{r4, r5, r6, pc}
 234              	.L27:
 235              		.align	2
 236              	.L26:
 237 0068 00000000 		.word	.LANCHOR1
 238 006c 1CC00920 		.word	537509916
 239 0070 18C00920 		.word	537509912
 240 0074 00000000 		.word	.LANCHOR0
 241              	.LBE5:
 242              		.cfi_endproc
 243              	.LFE4:
 245              		.section	.bss.timeRead.4270,"aw",%nobits
 246              		.align	2
 247              		.set	.LANCHOR1,. + 0
 250              	timeRead.4270:
 251 0000 00000000 		.space	4
 252              		.section	.bss.joy,"aw",%nobits
 253              		.align	2
 254              		.set	.LANCHOR0,. + 0
 257              	joy:
 258 0000 00000000 		.space	4
 259              		.text
 260              	.Letext0:
 261              		.file 2 "uc_libc_dev/_libdef/uc_libdefs.h"
 262              		.file 3 "uc_libc_dev/_arch/arm_lpc/spi/ssp1.h"
DEFINED SYMBOLS
                            *ABS*:00000000 joyps.c
D:\_temp\_windows\cc6qWR3c.s:20     .text.__swap:00000000 $t
D:\_temp\_windows\cc6qWR3c.s:24     .text.__swap:00000000 __swap
D:\_temp\_windows\cc6qWR3c.s:69     .text.joy_Init:00000000 $t
D:\_temp\_windows\cc6qWR3c.s:74     .text.joy_Init:00000000 joy_Init
D:\_temp\_windows\cc6qWR3c.s:98     .text.joy_Init:0000001c $d
D:\_temp\_windows\cc6qWR3c.s:105    .text.joy_Read:00000000 $t
D:\_temp\_windows\cc6qWR3c.s:110    .text.joy_Read:00000000 joy_Read
D:\_temp\_windows\cc6qWR3c.s:131    .text.joy_Read:0000000c $d
D:\_temp\_windows\cc6qWR3c.s:136    .text.joy_Tick:00000000 $t
D:\_temp\_windows\cc6qWR3c.s:141    .text.joy_Tick:00000000 joy_Tick
D:\_temp\_windows\cc6qWR3c.s:237    .text.joy_Tick:00000068 $d
D:\_temp\_windows\cc6qWR3c.s:246    .bss.timeRead.4270:00000000 $d
D:\_temp\_windows\cc6qWR3c.s:250    .bss.timeRead.4270:00000000 timeRead.4270
D:\_temp\_windows\cc6qWR3c.s:253    .bss.joy:00000000 $d
D:\_temp\_windows\cc6qWR3c.s:257    .bss.joy:00000000 joy
                     .debug_frame:00000010 $d

UNDEFINED SYMBOLS
ssp1_TransferByte
